Many developments in connection with processor systems and, particularly, in connection with optimizing compilers, have been directed to increasing the speed or efficiency of processor computational operations. Faster or more efficient processor computational operations can result in faster program execution times, particularly if the fundamental procedures or computational operations that are the building blocks of an overall program can be made faster or more efficient. For example, the process of finding a quotient and remainder value associated with a division operation is a well-known fundamental procedure or computational operation.
In general, the process of performing a division operation and calculating a related remainder value is relatively more computationally intensive and expensive in terms of processor usage than more basic arithmetic operations such as addition and multiplication. However, many efficient techniques for calculating a quotient and a remainder are in widespread use. For example, for a divisor that is known at compile time and that is runtime invariant, it is possible to more efficiently or quickly calculate quotient values associated with runtime variant dividends using multiplication operations involving a value associated with a reciprocal of the runtime invariant divisor.
A processor system may determine a remainder value of interest by first performing a division operation. Often, a remainder value is of greater interest than a quotient. For example, when a processor system executes a modulus instruction, only a remainder value associated with a divisor value and a dividend value is returned.
One known technique for calculating a remainder is based on knowing the divisor value at compile time and that the divisor value is runtime invariant. Because the divisor value is known at compile time, a scaled approximate reciprocal of the divisor value can be calculated and pre-stored (i.e., prior to runtime), thereby enabling a processor system to calculate, during runtime, a quotient and remainder using a multiplication of the dividend and the scaled approximate reciprocal of the divisor value. In particular, a quotient may be calculated at runtime by augmenting the multiplication with a bit shift or bit extraction to compensate for the scaling of the reciprocal value. The remainder value can then be calculated by subtracting the product of the divisor and the quotient from the dividend.
Although the above-described quotient and remainder calculation technique is relatively efficient in many instances, it treats all combinations of dividend and divisor values in the same manner and does not consider more efficient solutions for specific dividend and divisor value combinations. Thus, traditional methods of computing quotient and remainder values within processor systems typically require the same amount of computational work or processor usage, regardless of whether a less computationally intensive technique may be employed.